<?php
class Helper_Smsapi
{
    /**
     * 短信发送接口
     * 
     * @param string $telephone         接收短信的号码。多个号码之间以分号分隔，每次最多50个
     * @param string $message           发送的信息
     * @return int
     */
    public static function sendSms( $telephone , $message )
    {
        
        if( strlen( rawurlencode( '码' ) ) > 7 )
        {
            $url = 'utf';
        }
        else
        {
            $url = 'gb';
        }
        
        $smsConfig = Common::getConfig( 'SystemConfig' );
        print_r($smsConfig);
        $url = $smsConfig['url'] . $url . '.asp?usr=' . rawurlencode( $smsConfig['account'] ) . '&pwd=' . rawurlencode( $smsConfig['mysqlDb']['data']['passwd'] );
        $url = $url . '&tel=' . rawurlencode( $telephone ) . '&msg=' . rawurlencode( $message );
        
        $content = @file_get_contents( $url );
        
        if( !is_numeric( $content ) )
        {
            $content = 0;
        }
        
        //增加日志
        Helper_Log::add( 'sendMsg' , array( 'msg' => $message , 'mobile' => $telephone , 'result' => $content ) );
        
        return (int)$content;
    }
}
?>
